ALMaSS  1.0
The Animal, Landscape and Man Simulation System
Roe_Male Class Reference

#include <Roe_all.h>

Inheritance diagram for Roe_Male:
Roe_Adult_Base Roe_Base TAnimal TALMaSSObject

Public Member Functions

void On_Expelled (Roe_Male *rival)
 
void On_NewHost (Roe_Male *host)
 
void On_ApproachOfDanger (int p_To_x, int p_To_y)
 
bool On_InHeat (Roe_Female *female, int p_x, int p_y)
 
void ClearFightlist ()
 
bool SupplyHaveTerritory ()
 
Roe_MaleSupplyHost ()
 
bool On_Rank (Roe_Male *rival, double size, int age, int matings, bool where, bool range)
 
virtual void On_IsDead (Roe_Base *Someone, int whos_dead, bool fawn)
 
void AddSatellite (Roe_Male *sat)
 
void RemoveSatellite (Roe_Male *sat)
 
void Init (void)
 
virtual void BeginStep (void)
 
virtual void Step (void)
 
virtual void EndStep (void)
 
 Roe_Male (int x, int y, int size, int age, Roe_Female *mum, Landscape *L, RoeDeer_Population_Manager *RPM)
 
virtual ~Roe_Male ()
 
- Public Member Functions inherited from Roe_Adult_Base
 Roe_Adult_Base (int x, int y, int size, int age, Landscape *L, RoeDeer_Population_Manager *RPM)
 
virtual ~Roe_Adult_Base ()
 
- Public Member Functions inherited from Roe_Base
unsigned IsAlive ()
 
int SupplyReserves ()
 
virtual void On_MumAbandon (Roe_Female *)
 
virtual void On_EndGroup ()
 
virtual void Send_IsDead ()
 
virtual void On_ChangeGroup (int)
 
virtual void On_UpdateGroup (int, int)
 
RoeDeerInfo SupplyInfo ()
 
virtual int WhatState ()
 
 Roe_Base (int x, int y, Landscape *L, RoeDeer_Population_Manager *RPM)
 
virtual ~Roe_Base ()
 
- Public Member Functions inherited from TAnimal
unsigned SupplyFarmOwnerRef ()
 
AnimalPosition SupplyPosition ()
 
APoint SupplyPoint ()
 
int SupplyPolygonRef ()
 
int Supply_m_Location_x ()
 
int Supply_m_Location_y ()
 
virtual void KillThis ()
 
virtual void CopyMyself ()
 
void SetX (int a_x)
 
void SetY (int a_y)
 
 TAnimal (int x, int y, Landscape *L)
 
virtual void ReinitialiseObject (int x, int y, Landscape *L)
 Used to re-use an object - must be implemented in descendent classes. More...
 
virtual void Dying ()
 
void CheckManagement (void)
 
void CheckManagementXY (int x, int y)
 
virtual bool OnFarmEvent (FarmToDo)
 
- Public Member Functions inherited from TALMaSSObject
int GetCurrentStateNo ()
 Returns the current state number. More...
 
void SetCurrentStateNo (int a_num)
 Sets the current state number. More...
 
bool GetStepDone ()
 Returns the step done indicator flag. More...
 
void SetStepDone (bool a_bool)
 Sets the step done indicator flag. More...
 
virtual void ReinitialiseObject ()
 Used to re-use an object - must be implemented in descendent classes. More...
 
 TALMaSSObject ()
 The constructor for TALMaSSObject. More...
 
virtual ~TALMaSSObject ()
 The destructor for TALMaSSObject. More...
 
void OnArrayBoundsError ()
 Used for debugging only, tests basic object properties. More...
 

Public Attributes

int m_MinInState [12]
 
- Public Attributes inherited from Roe_Base
TRoeDeerStates CurrentRState
 
RoeDeer_Population_Managerm_OurPopulation
 
int m_Age
 
int m_Size
 
int m_RangeCentre_x
 
int m_RangeCentre_y
 
int m_Reserves
 
double m_HomeRange
 
int m_OldRange_x
 
int m_OldRange_y
 
int m_SearchRange
 
bool m_float
 
bool m_Disperse
 
bool m_HaveRange
 
Roe_FemaleMum
 
int m_ID
 
int m_FixlistNumber
 
bool m_Sex
 
bool m_IsDead
 
unsigned Alive
 

Protected Member Functions

int MOnMature (void)
 
int MDie (void)
 
int MDisperse (void)
 
int MEstablishRange (void)
 
int MOnNewDay (void)
 
int MEstablishTerritory (void)
 
int MFight (void)
 
int MAttendFemale (void)
 
int MFeed (void)
 
int MRun ()
 
int MRecover (void)
 
int MEvade ()
 
int MIgnore ()
 
int MRuminate (void)
 
int MMate (void)
 
int MUpdateEnergy (void)
 
- Protected Member Functions inherited from Roe_Base
bool Running (int x, int y)
 
void Ignore (int p_To_x, int p_To_y)
 
int DistanceTo (int p_x, int p_y, int p_To_x, int p_To_y)
 
int DistanceToCC (int p_x, int p_y, int p_To_x, int p_To_y)
 
int DirectionTo (int p_x, int p_y, int p_To_x, int p_To_y)
 
int DirectionToCC (int p_x, int p_y, int p_To_x, int p_To_y)
 
int NextStep (int weight, int dir, int recurselevel)
 
int AssessHabitat (int polyref)
 
int AssessHabitat (int p_x, int p_y)
 
int LegalHabitat (int p_x, int p_y)
 
int LegalHabitatCC (int p_x, int p_y)
 
int Cover (int polyref)
 Calls the cover calculation for a given polyref. More...
 
int Cover (int p_x, int p_y)
 Calls the cover calculation for a given x,y location. More...
 
int CalcCover (TTypesOfLandscapeElement a_ele, int a_poly)
 The cover calculation for a given element type. More...
 
int CoverCC (int p_x, int p_y)
 
int NutriValue (int polyref)
 
int NutriValue (int p_x, int p_y)
 
int NutriValueCC (int p_x, int p_y)
 
int Feeding (bool p_Disperse)
 
void SeekCover (int threshold)
 
void SeekNutri (int p_threshold)
 
int ProbRoadCross (int p_x, int p_y, int p_width)
 
double CalculateRoadMortality (int p_x, int p_y, int p_width)
 
void WalkTo (int pos_x, int pos_y)
 
void WalkToCC (int pos_x, int pos_y)
 
- Protected Member Functions inherited from TAnimal
void CorrectWrapRound ()
 Corrects wrap around co-ordinate problems. More...
 

Protected Attributes

Roe_Femalem_My_Mate
 
bool m_HaveTerritory
 
int m_NoOfMatings
 
int m_NumberOfFights
 
int m_MyFightlist
 
Roe_Malem_MyTMale
 
Roe_Malem_MySatellites [50]
 
- Protected Attributes inherited from Roe_Adult_Base
bool m_DestinationDecided
 
int m_NewState
 
int m_DispCount
 
int m_float_x
 
int m_float_y
 
- Protected Attributes inherited from Roe_Base
int timestep
 
int m_Cross_x
 
int m_Cross_y
 
double m_EnergyGained
 
int m_RecovCount
 
int m_RumiCount
 
int m_FeedCount
 
int m_LengthFeedPeriod
 
int m_LengthRuminate
 
int m_LastState
 
int m_danger_x
 
int m_danger_y
 
int m_distrc
 
int m_weightedstep
 
int SimW
 
int SimH
 
- Protected Attributes inherited from TAnimal
int m_Location_x
 
int m_Location_y
 
Landscapem_OurLandscape
 
- Protected Attributes inherited from TALMaSSObject
int m_CurrentStateNo
 The basic state number for all objects - '-1' indicates death. More...
 
bool m_StepDone
 Indicates whether the iterative step code is done for this timestep. More...
 

Constructor & Destructor Documentation

◆ Roe_Male()

Roe_Male::Roe_Male ( int  x,
int  y,
int  size,
int  age,
Roe_Female mum,
Landscape L,
RoeDeer_Population_Manager RPM 
)

Roe_Male::Roe_Male - constructor for male object. Sets all attributes. It also adds fawns to mother's offspring list.

1394  :Roe_Adult_Base (x,y,size,age,L,RPM)
1395 {
1396  m_Age = age;
1397  m_Sex=true;
1398  Mum=mum;
1399  //add yourself to mothers offspring list
1400  if(Mum!=NULL)
1401  {
1402  #ifdef JUJ__Debug3
1403  if(Mum->IsAlive()!=0x0DEADC0DE)
1404  {
1405  m_OurLandscape ->Warn("Roe_Male::Roe_Male():Deadcode warning, Mum","");
1406  exit( 1 );
1407  }
1408  #endif
1409  for(int i=0;i<20;i++)
1410  {
1411  if(Mum->m_MyYoung[i]==NULL)
1412  {
1413  Mum->m_MyYoung[i]=this;
1414  break;
1415  }
1416  }
1417  }
1418  m_HaveTerritory = false;
1419  m_HaveRange = false;
1420  m_My_Mate = NULL;
1421  m_MyTMale = NULL;
1422  m_Reserves = 30;
1423  m_IsDead=false;
1424  m_LastState=36; //Feed. Could be any safe state
1425  m_NoOfMatings = 0;
1426  m_NumberOfFights = 0;
1427  m_MyFightlist=-1; //created when needed
1428  if(size==-1) //1st generation roe
1429  {
1430  int rand = random(2000);
1431  m_Size = 17000 + rand; //just for the first generation, to make sure that
1432  //some are dispersers and some are not
1433  }
1434  else m_Size=size;
1435  for (int i=0;i<12;i++) m_MinInState[i] = 0;
1436  for(unsigned i=0;i<50;i++) m_MySatellites[i]=NULL;
1437 }
int random(int a_range)
Definition: ALMaSS_CmdLine.cpp:142
void Warn(std::string a_msg1, std::string a_msg2)
Definition: landscape.h:1579
Roe_Adult_Base(int x, int y, int size, int age, Landscape *L, RoeDeer_Population_Manager *RPM)
Definition: Roe_adult.cpp:40
bool m_Sex
Definition: Roe_all.h:120
bool m_IsDead
Definition: Roe_all.h:121
int m_Size
Definition: Roe_all.h:106
Roe_Female * Mum
Definition: Roe_all.h:117
bool m_HaveRange
Definition: Roe_all.h:116
int m_LastState
Definition: Roe_all.h:138
int m_Reserves
Definition: Roe_all.h:109
int m_Age
Definition: Roe_all.h:105
unsigned IsAlive()
Definition: Roe_all.h:123
Roe_Base * m_MyYoung[20]
Definition: Roe_all.h:311
Roe_Female * m_My_Mate
Definition: Roe_all.h:384
bool m_HaveTerritory
Definition: Roe_all.h:386
Roe_Male * m_MyTMale
Definition: Roe_all.h:390
Roe_Male * m_MySatellites[50]
Definition: Roe_all.h:391
int m_NoOfMatings
Definition: Roe_all.h:387
int m_MinInState[12]
Definition: Roe_all.h:412
int m_NumberOfFights
Definition: Roe_all.h:388
int m_MyFightlist
Definition: Roe_all.h:389
Landscape * m_OurLandscape
Definition: PopulationManager.h:229

References Roe_Base::IsAlive(), Roe_Base::m_Age, Roe_Base::m_HaveRange, m_HaveTerritory, Roe_Base::m_IsDead, Roe_Base::m_LastState, m_MinInState, m_My_Mate, m_MyFightlist, m_MySatellites, m_MyTMale, Roe_Female::m_MyYoung, m_NoOfMatings, m_NumberOfFights, TAnimal::m_OurLandscape, Roe_Base::m_Reserves, Roe_Base::m_Sex, Roe_Base::m_Size, Roe_Base::Mum, random(), and Landscape::Warn().

◆ ~Roe_Male()

Roe_Male::~Roe_Male ( )
virtual
1440 {
1441  m_My_Mate=NULL;
1442  Mum=NULL;
1443 }

References m_My_Mate, and Roe_Base::Mum.

Member Function Documentation

◆ AddSatellite()

void Roe_Male::AddSatellite ( Roe_Male sat)

Roe_Male::AddSatellite - adds satellite male to a male object's satellite male list.

1698 {
1699  #ifdef JUJ__Debug3
1700  if(sat->IsAlive()!=0x0DEADC0DE)
1701  {
1702  m_OurLandscape ->Warn("Roe_Male::AddSatellite():Deadcode warning, sat!","");
1703  exit( 1 );
1704  }
1705  #endif
1706  bool found=false;
1707  //add new satellite male to your list
1708  for(unsigned i=0;i<50;i++)
1709  {
1710  if(m_MySatellites[i]==NULL)
1711  {
1712  m_MySatellites[i]=sat;
1713  found=true;
1714  break;
1715  }
1716  }
1717  if(!found)
1718  {
1719  m_OurLandscape ->Warn("Roe_Male::AddSatellite():List is full!","");
1720  exit( 1 );
1721  }
1722 }

References Roe_Base::IsAlive(), m_MySatellites, TAnimal::m_OurLandscape, and Landscape::Warn().

Referenced by MEstablishRange(), and On_NewHost().

◆ BeginStep()

void Roe_Male::BeginStep ( void  )
virtual

Roe_Male::BeginStep goes through all male objects in the populations. Male objects holding a territory, (in the territorial season, March 1st - Sept. 1st) check territory for other male objects every 4 hours. OnRank() keep track of male ranks. These ranks lasts for the rest of that season (i.e. m_FightList is cleared once a year). Young satellite males always try to stay clear of their older host and check distance every timestep and evade if too close Calls SupplyMonth(), SupplyMales(), On_Rank(), AddToFightList(), SupplyPosition(), DistanceTo().

Reimplemented from Roe_Adult_Base.

979 {
980  #ifdef JUJ__Debug3
981  if(IsAlive()!=0x0DEADC0DE)
982  {
983  m_OurLandscape ->Warn("Roe_Male::BeginStep(): Deadcode warning!","");
984  exit( 1 );
985  }
986  #endif
987  if (CurrentRState==rds_MDeathState) return;
988  //In the territorial season (March 1st - Sept. 1st) territoryholders have to
989  //check their area for other males. Whenever they meet a new male ranks
990  //are established, which lasts for the rest of that season (i.e. m_FightList is
991  //cleared once a year).
992  //TMales search the area every 4 hours.
993  int month=m_OurLandscape->SupplyMonth();
994  if((month>=3)&&(month<=8))
995  {
996  if((m_HaveTerritory==true)&&(timestep%24==0))
997  {
998  //get other males in area
1000  if(males!=NULL) //only if other males are present
1001  {
1002  for(unsigned i=0;i<males->size();i++)
1003  {
1004  if((*males)[i]!=this) //don't challenge yourself
1005  {
1006  (*males)[i]->On_Rank(this,(double) m_Size,m_Age,m_NoOfMatings,true,true); //need to establish rank
1007  //add each to fightlist
1008  m_NumberOfFights++;
1009  m_MinInState[7]++; //to place cost per fight in update energy
1011  }
1012  }
1013  }
1014  delete males;
1015  }
1016  }
1017  //Young satellite males always try to stay clear of their older host
1018  //check distance every timestep and evade if too close
1019  if((m_MyTMale!=NULL)&&(m_MyTMale->IsAlive()==0x0DEADC0DE)) //young satellite male
1020  {
1022  if(DistanceTo(m_Location_x,m_Location_y,xy.m_x,xy.m_y) < 50)
1023  {
1025  }
1026  }
1027 }
@ rds_MEvade
Definition: Roe_all.h:74
@ rds_MDeathState
Definition: Roe_all.h:91
vector< Roe_Male * > ListOfMales
Definition: Roe_all.h:39
A class defining an animals position.
Definition: PopulationManager.h:170
unsigned m_x
Definition: PopulationManager.h:172
unsigned m_y
Definition: PopulationManager.h:173
int SupplyMonth(void)
Definition: landscape.h:1601
RoeDeer_Population_Manager * m_OurPopulation
Definition: Roe_all.h:104
int timestep
Definition: Roe_all.h:128
int m_SearchRange
Definition: Roe_all.h:113
int DistanceTo(int p_x, int p_y, int p_To_x, int p_To_y)
Definition: Roe_base.cpp:784
TRoeDeerStates CurrentRState
Definition: Roe_all.h:103
int AddToFightlist(Roe_Male *rival, int ListNo)
Definition: Roe_Population_Manager.cpp:1527
ListOfMales * SupplyMales(int p_x, int p_y, int SearchRange)
Definition: Roe_Population_Manager.cpp:1154
int m_Location_y
Definition: PopulationManager.h:228
AnimalPosition SupplyPosition()
Definition: PopulationManager.cpp:1345
int m_Location_x
Definition: PopulationManager.h:225

References RoeDeer_Population_Manager::AddToFightlist(), Roe_Base::CurrentRState, Roe_Base::DistanceTo(), Roe_Base::IsAlive(), Roe_Base::m_Age, m_HaveTerritory, TAnimal::m_Location_x, TAnimal::m_Location_y, m_MinInState, m_MyFightlist, m_MyTMale, m_NoOfMatings, m_NumberOfFights, TAnimal::m_OurLandscape, Roe_Base::m_OurPopulation, Roe_Base::m_SearchRange, Roe_Base::m_Size, AnimalPosition::m_x, AnimalPosition::m_y, rds_MDeathState, rds_MEvade, RoeDeer_Population_Manager::SupplyMales(), Landscape::SupplyMonth(), TAnimal::SupplyPosition(), Roe_Base::timestep, and Landscape::Warn().

◆ ClearFightlist()

void Roe_Male::ClearFightlist ( )
1758 {
1759  m_MyFightlist=-1;
1760  m_NumberOfFights=0;
1761 }

References m_MyFightlist, and m_NumberOfFights.

Referenced by RoeDeer_Population_Manager::DoFirst().

◆ EndStep()

void Roe_Male::EndStep ( void  )
virtual

Roe_Male::EndStep - checks if male object is dead and adds to number of timesteps. If 1 whole day has passed, current state is set to FOnNewDay

Reimplemented from Roe_Adult_Base.

1370 {
1371  #ifdef JUJ__Debug3
1372  if(IsAlive()!=0x0DEADC0DE)
1373  {
1374  m_OurLandscape ->Warn("Roe_Male::EndStep():Deadcode warning!","");
1375  exit( 1 );
1376  }
1377  #endif
1378  if (CurrentRState==rds_MDeathState) return;
1379 
1380  timestep++;
1381  if (m_OurPopulation->StepCounter %144==0) //1 day has passed
1382  {
1383  m_weightedstep=0;
1385  }
1386 
1387 }
@ rds_MOnNewDay
Definition: Roe_all.h:59
int m_weightedstep
Definition: Roe_all.h:143
long StepCounter
Definition: Roe_all.h:505

References Roe_Base::CurrentRState, Roe_Base::IsAlive(), TAnimal::m_OurLandscape, Roe_Base::m_OurPopulation, Roe_Base::m_weightedstep, rds_MDeathState, rds_MOnNewDay, RoeDeer_Population_Manager::StepCounter, Roe_Base::timestep, and Landscape::Warn().

◆ Init()

void Roe_Male::Init ( void  )

◆ MAttendFemale()

int Roe_Male::MAttendFemale ( void  )
protected

Roe_Male::MAttendFemale - function for male attending female in heat. Checks if has mate, if not return to feeding. If has a mate, male stays in this state (attend female) until new day. Then he returns to normal activity. The male will attend to the female, and follow her closely. He does not eat during that day and looses energy comparable to walking. Calls SupplyPosition(), WalkTo().

607 {
608  //male stays in this state until new day. Then he returns to normal activity
609  #ifdef JUJ__Debug3
610  if(IsAlive()!=0x0DEADC0DE)
611  {
612  m_OurLandscape ->Warn("Roe_Male::MAttendFemale(): Deadcode warning!","");
613  exit( 1 );
614  }
615  #endif
616  if(m_My_Mate==NULL) return 36;
617  else
618  {
619  #ifdef JUJ__Debug3
620  if(m_My_Mate->IsAlive()!=0x0DEADC0DE)
621  {
622  m_OurLandscape ->Warn("Roe_Male::MAttendFemale(): Deadcode warningm m_My_Mate!","");
623  exit( 1 );
624  }
625  #endif
626  m_MinInState[8]++; //add 1 to time spend in this state
627  //allow roe to return after disturbance
628  m_LastState=31;
629  //While attending the female the male follows her closely. He does not eat
630  //during that day and looses energy comparable to walking.
631  //get females position
633  WalkTo(xy.m_x,xy.m_y);
634  return 31; //Attendfemale
635  }
636 }
void WalkTo(int pos_x, int pos_y)
Definition: Roe_base.cpp:1119

References Roe_Base::IsAlive(), Roe_Base::m_LastState, m_MinInState, m_My_Mate, TAnimal::m_OurLandscape, AnimalPosition::m_x, AnimalPosition::m_y, TAnimal::SupplyPosition(), Roe_Base::WalkTo(), and Landscape::Warn().

Referenced by Step().

◆ MDie()

int Roe_Male::MDie ( void  )
protected

Roe_Male::MDie - function for managing death of a male object. The male object removes itself from all fightlists and deletes its own fightlist. The fixlist of the male object is emptied and the male furthermore adds itself to list of dead animals. If a territoryholder sends message to every male in the neighbourhood abput death. Messages potential mate and satellite males about death. Function returns dead state. Calls functions DeleteFightList(), RemoveFromFightList(), RemoveFixList()and On_IsDead().

862 {
863  #ifdef JUJ__Debug3
864  if(IsAlive()!=0x0DEADC0DE)
865  {
866  m_OurLandscape ->Warn("Roe_Male::MDie(): Deadcode warning!","");
867  exit( 1 );
868  }
869  #endif
870  m_CurrentStateNo = -1;
871  //remove yourself from all fightlists and delete your own fightlist
872  if(m_MyFightlist!=-1)
873  {
875  m_MyFightlist=-1;
876  }
878  //empty the fixlist of this animal
880 
881  //add yourself to list of dead animals
882  for(int i=0;i<2000;i++)
883  {
884  if(m_OurPopulation->DeadList[i][0] == 0) //empty entrance
885  {
886  m_OurPopulation->DeadList[i][0] = 1; //'1' for male, '2' for female
887  m_OurPopulation->DeadList[i][1] = m_Age; //age in days
888  break;
889  }
890  }
891  //tell everybody who needs to know
892  if(Mum!=NULL) //tell mum
893  {
894  #ifdef JUJ__Debug3
895  if(Mum->IsAlive()!=0x0DEADC0DE)
896  {
897  m_OurLandscape ->Warn("Roe_Male::MDie(): Deadcode warning,Mum!","");
898  exit( 1 );
899  }
900  #endif
901  Mum->On_IsDead(this,3,false); //'3' indicates offspring
902  Mum=NULL; //remove pointer
903  }
904 
905  if (m_My_Mate!=NULL) //tell mate
906  {
907  #ifdef JUJ__Debug3
908  if(m_My_Mate->IsAlive()!=0x0DEADC0DE)
909  {
910  m_OurLandscape ->Warn("Roe_Male::MDie(): Deadcode warning, m_My_Mate!","");
911  exit( 1 );
912  }
913  #endif
914  m_My_Mate->On_IsDead(this,2,false); //'2' indicates mate
915  m_My_Mate=NULL; //remove pointer
916  }
917 
918  for(unsigned i=0;i<50;i++) //tell satellite males
919  {
920  if(m_MySatellites[i]!=NULL)
921  {
922  #ifdef JUJ__Debug3
923  if(m_MySatellites[i]->IsAlive()!=0x0DEADC0DE)
924  {
925  m_OurLandscape ->Warn("Roe_Male::MDie(): Deadcode warning, m_MySatellites[i]!","");
926  exit( 1 );
927  }
928  #endif
929  m_MySatellites[i]->On_IsDead(this,1,false); //'1' indicates male
930  }
931  }
932 
933  if(m_MyTMale!=NULL) //tell host
934  {
935  #ifdef JUJ__Debug3
936  if(m_MyTMale->IsAlive()!=0x0DEADC0DE)
937  {
938  m_OurLandscape ->Warn("Roe_Male::MDie(): Deadcode warning, m_MyTMale!","");
939  exit( 1 );
940  }
941  #endif
942  m_MyTMale->On_IsDead(this,1,false);
943  m_MyTMale=NULL; //remove pointer
944  }
945  //if a territoryholder every male in the neighbourhood needs to know
946  if(m_HaveTerritory==true)
947  {
948  //get list of males in area
950  for(unsigned i=0;i<males->size();i++)
951  {
952  #ifdef JUJ__Debug3
953  if((*males)[i]->IsAlive()!=0x0DEADC0DE)
954  {
955  m_OurLandscape ->Warn("Roe_Male::MDie(): Deadcode warning, (*males)[i]!","");
956  exit( 1 );
957  }
958  #endif
959  if((*males)[i]!=this) //don't send to yourself
960  {
961  (*males)[i]->On_IsDead(this,1, false);
962  }
963  }
964  delete males;
965  }
966  return 45; //MDeathState
967 }
int m_FixlistNumber
Definition: Roe_all.h:119
virtual void On_IsDead(Roe_Base *Someone, int whos_dead, bool fawn)
Definition: Roe_female.cpp:1925
virtual void On_IsDead(Roe_Base *Someone, int whos_dead, bool fawn)
Definition: Roe_male.cpp:1504
void RemoveFixList(int listno)
Definition: Roe_Population_Manager.cpp:1346
int DeadList[2000][2]
Definition: Roe_all.h:504
void DeleteFightlist(int TheList)
Definition: Roe_Population_Manager.cpp:1627
void RemoveFromFightlist(Roe_Base *deer)
Definition: Roe_Population_Manager.cpp:1489
int m_CurrentStateNo
The basic state number for all objects - '-1' indicates death.
Definition: PopulationManager.h:116

References RoeDeer_Population_Manager::DeadList, RoeDeer_Population_Manager::DeleteFightlist(), Roe_Base::IsAlive(), Roe_Base::m_Age, TALMaSSObject::m_CurrentStateNo, Roe_Base::m_FixlistNumber, m_HaveTerritory, TAnimal::m_Location_x, TAnimal::m_Location_y, m_My_Mate, m_MyFightlist, m_MySatellites, m_MyTMale, TAnimal::m_OurLandscape, Roe_Base::m_OurPopulation, Roe_Base::m_SearchRange, Roe_Base::Mum, Roe_Female::On_IsDead(), On_IsDead(), RoeDeer_Population_Manager::RemoveFixList(), RoeDeer_Population_Manager::RemoveFromFightlist(), RoeDeer_Population_Manager::SupplyMales(), and Landscape::Warn().

Referenced by Step().

◆ MDisperse()

int Roe_Male::MDisperse ( void  )
protected

Roe_Male::MDisperse - models dispersal state of male objects. Removes satellite males, sets state to dispersal. It then keeps track of amount of time in the dispersal state and calculates probability of switching to feeding, keep dispersing, or dying if spending too long in dispersal state.Calls functions RemoveSatellite(), DirectionTo(), NextStep().

137 {
138  #ifdef JUJ__Debug3
139  if(IsAlive()!=0x0DEADC0DE)
140  {
141  m_OurLandscape ->Warn("Roe_Male::MDisperse(): Deadcode warning!","");
142  exit( 1 );
143  }
144  #endif
145  if(m_MyTMale!=NULL)
146  {
147  m_MyTMale->RemoveSatellite(this);
148  m_MyTMale=NULL;
149  }
150  m_DispCount++;
151  m_MinInState[2]++; //add 1 to time spend in this state
152  m_HaveRange=false; //a dispersing animal cannot be a rangeholder per def.
153  m_HaveTerritory=false;
154  m_Disperse=true; //indicates that dispersal has started
155  //allow buck the opportunity to return to this state after disturbance
156  m_LastState=11;
157  if(m_DispCount==1) //first timestep in disperse
158  {
159  //store range centre coordinates while dispersing
162  }
163  m_RangeCentre_x=m_Location_x; //these are drifting depending on bucks position
165  //int dist=DistanceTo(m_Location_x,m_Location_y,m_OldRange_x,m_OldRange_y);
167  int rand=0;
168  if(m_DispCount>70)
169  {
170  for(int i=0;i<3;i++)
171  {
172  if( NextStep(0,0,0) == -1) return 42; //
173  }
174  }
175  else
176  {
177  for(int i=0;i<3;i++)
178  {
179  if( NextStep(1,((dir+4) & 0x07),0) == -1) return 42;
180  }
181  }
182 
183  switch (m_DispCount)
184  {
185  case 40:
186  rand=40;
187  break;
188  case 50:
189  rand=60;
190  break;
191  case 60:
192  rand=80;
193  break;
194  default:
195  if(m_DispCount>=70) rand=90;
196  break;
197  }
198 
199  if (rand>random(100))
200  {
201  return 36;
202  }
203  else return 11;
204 }
int m_DispCount
Definition: Roe_all.h:239
int DirectionTo(int p_x, int p_y, int p_To_x, int p_To_y)
Definition: Roe_base.cpp:802
int m_RangeCentre_y
Definition: Roe_all.h:108
int m_OldRange_y
Definition: Roe_all.h:112
int m_OldRange_x
Definition: Roe_all.h:111
bool m_Disperse
Definition: Roe_all.h:115
int m_RangeCentre_x
Definition: Roe_all.h:107
int NextStep(int weight, int dir, int recurselevel)
Definition: Roe_base.cpp:1242
void RemoveSatellite(Roe_Male *sat)
Definition: Roe_male.cpp:1727

References Roe_Base::DirectionTo(), Roe_Base::IsAlive(), Roe_Adult_Base::m_DispCount, Roe_Base::m_Disperse, Roe_Base::m_HaveRange, m_HaveTerritory, Roe_Base::m_LastState, TAnimal::m_Location_x, TAnimal::m_Location_y, m_MinInState, m_MyTMale, Roe_Base::m_OldRange_x, Roe_Base::m_OldRange_y, TAnimal::m_OurLandscape, Roe_Base::m_RangeCentre_x, Roe_Base::m_RangeCentre_y, Roe_Base::NextStep(), random(), RemoveSatellite(), and Landscape::Warn().

Referenced by Step().

◆ MEstablishRange()

int Roe_Male::MEstablishRange ( void  )
protected

Roe_Male::MEstablishRange - sets up range for male object. Contrary to the females, males does not just set up range in their mothers´territory. They have to position themselves according to the distribution of male territories in the area. Two strategies: 1)satellite and 2)periphere. Males heavier than average for their age class choose satellite and set rangecentre= oldest male in area. Others choose periphere and avoid other males. Sets range center. Returns state feed. Calls functions SupplyTMales(), SupplyInfo(), AddSatellite()

74 {
75  #ifdef JUJ__Debug3
76  if(IsAlive()!=0x0DEADC0DE)
77  {
78  m_OurLandscape ->Warn("Roe_Male::MEstablishRange(): Deadcode warning!","");
79  exit( 1 );
80  }
81  #endif
82  //contrary to the females, males does not just set up range in their mothers
83  //territory. They have to position themselves according to the distribution of male
84  //territories in the area. Two strategies: 1)satellite and 2)periphere. Males
85  //heavier than average for their ageclass choose satellite and set rangecentre=
86  //oldest male in area. Others choose periphere and avoid other males
87 
88  m_MyTMale=NULL;
89  m_MinInState[0]++; //add 1 to timesteps spend in this state
90  //Get list of TMales in area
91  ListOfMales* males = m_OurPopulation->
92  SupplyTMales(m_Location_x,m_Location_y,1000);
93  if((males->size()>0)&&(m_Size > m_OurPopulation->m_MaleDispThreshold))
94  { //use satellite strategy
95  //Choose the oldest male on list
96  int oldest=0;
97  for (unsigned i=0; i< males->size(); i++)
98  {
99  #ifdef JUJ__Debug3
100  if((*males)[i]->IsAlive()!=0x0DEADC0DE)
101  {
102  m_OurLandscape ->Warn("Roe_Male::MOnMature(): Deadcode warning, (*males)[i]!","");
103  exit( 1 );
104  }
105  #endif
106  RoeDeerInfo info=(*males)[i]->SupplyInfo();
107  if (info.m_Age>oldest)
108  {
109  oldest=info.m_Age;
110  m_RangeCentre_x=info.m_Range_x; //set your rangecentre=his
112  m_MyTMale=(*males)[i];
113  }
114  }
115  m_MyTMale->AddSatellite(this);
116  }
117  else //Either a periphere male or no males in area. Establish range on spot
118  {
121  }
122  m_HaveRange=true;
123  m_Disperse=false;
124  m_float=false;
125  m_DispCount=0; //end of dipersal
126  delete males;
127  return 36;
128 }
bool m_float
Definition: Roe_all.h:114
void AddSatellite(Roe_Male *sat)
Definition: Roe_male.cpp:1697
int m_MaleDispThreshold
Definition: Roe_all.h:506
Part of the basic ALMaSS system (obselete)
Definition: PopulationManager.h:187
unsigned m_Range_y
Definition: PopulationManager.h:192
int m_Age
Definition: PopulationManager.h:190
unsigned m_Range_x
Definition: PopulationManager.h:191

References AddSatellite(), Roe_Base::IsAlive(), RoeDeerInfo::m_Age, Roe_Adult_Base::m_DispCount, Roe_Base::m_Disperse, Roe_Base::m_float, Roe_Base::m_HaveRange, TAnimal::m_Location_x, TAnimal::m_Location_y, RoeDeer_Population_Manager::m_MaleDispThreshold, m_MinInState, m_MyTMale, TAnimal::m_OurLandscape, Roe_Base::m_OurPopulation, RoeDeerInfo::m_Range_x, RoeDeerInfo::m_Range_y, Roe_Base::m_RangeCentre_x, Roe_Base::m_RangeCentre_y, Roe_Base::m_Size, and Landscape::Warn().

Referenced by Step().

◆ MEstablishTerritory()

int Roe_Male::MEstablishTerritory ( void  )
protected

Roe_Male::MEstablishTerritory - establishment of territory by male object. If male object is satellite male, the male challenges his host and adds him to fightlist. If Male is stronger it takes over the territory, otherwise no territory. If not a satellite male check all nearby males and establish rank by fighting them. If win take over their territory. Always returns state feeding. Calls AddToFightList(), On_Rank(), On_Expelled(), SupplyInfo(), SupplyTMales(),

284 {
285  #ifdef JUJ__Debug3
286  if(IsAlive()!=0x0DEADC0DE)
287  {
288  m_OurLandscape ->Warn("Roe_Male::MEstablishTerritory(): Deadcode warning!","");
289  exit( 1 );
290  }
291  #endif
292  m_MinInState[1]++; //add 1 to time spend in this state
293  bool result=false;
294  int defeated=-1;
295  if (m_MyTMale!=NULL) //challenge your host first
296  {
297  #ifdef JUJ__Debug3
298  if(m_MyTMale->IsAlive()!=0x0DEADC0DE)
299  {
300  m_OurLandscape ->Warn("Roe_Male::MEstablishTerritory(): Deadcode warning, m_MyTMale!","");
301  exit( 1 );
302  }
303  #endif
304  //Add host to fightlist
306 
307  if(m_MyTMale->On_Rank(this, double(m_Size), m_Age, m_NoOfMatings,false,false) == true)
308  { //you are stronger, take over territory
309  m_MyTMale->On_Expelled(this);
310 
312  m_RangeCentre_x=range.m_Range_x; //set your rangecentre=his
315  m_HaveTerritory=true;
316  m_Disperse=false;
317  m_DispCount=0;
318  m_MyTMale=NULL;
319  }
320  else //you lost to your host, situation is unchanged
321  {
323  }
324  }
325  else //don't have a host
326  {
327 
330  for(unsigned i=0; i<TMales->size(); i++) //for every male in area
331  {
332  #ifdef JUJ__Debug3
333  if((*TMales)[i]->IsAlive()!=0x0DEADC0DE)
334  {
335  m_OurLandscape ->Warn("Roe_Male::MEstablishTerritory(): Deadcode warning,(*Tmales)[i]!","");
336  exit( 1 );
337  }
338  #endif
339  //add this male to fightlist
342  m_MinInState[7]++; //to place cost on male for 1 fight
343  //send Rank-message to this male
344  result=(*TMales)[i]->On_Rank(this,double (m_Size),m_Age,m_NoOfMatings,false,false);
345  if(result) //this male won the fight
346  {
347  defeated=i;
348  break;
349  }
350  } //all males checked
351  if(defeated==-1) //list must have been empty
352  {
353  m_HaveTerritory=true;
356  m_Disperse=false;
357  m_DispCount=0;
358  }
359  else //must have won a fight. Can now take over that territory
360  {
361  RoeDeerInfo range=(*TMales)[defeated]->SupplyInfo();
362  m_HaveTerritory=true;
363  m_RangeCentre_x=range.m_Range_x; //set your rangecentre=his
365  //tell that male that he's been expelled from his territory
366  (*TMales)[defeated]->On_Expelled(this);
367  m_Disperse=false;
368  m_DispCount=0;
369  }
370  delete TMales;
371  }
372  return 36;//Feed
373 }
RoeDeerInfo SupplyInfo()
Definition: Roe_base.cpp:1668
bool On_Rank(Roe_Male *rival, double size, int age, int matings, bool where, bool range)
Definition: Roe_male.cpp:1772
void On_Expelled(Roe_Male *rival)
Definition: Roe_male.cpp:1894
ListOfMales * SupplyTMales(int p_x, int p_y, int SearchRange)
Definition: Roe_Population_Manager.cpp:1119

References RoeDeer_Population_Manager::AddToFightlist(), Roe_Base::IsAlive(), Roe_Base::m_Age, Roe_Adult_Base::m_DispCount, Roe_Base::m_Disperse, m_HaveTerritory, TAnimal::m_Location_x, TAnimal::m_Location_y, m_MinInState, m_MyFightlist, m_MyTMale, m_NoOfMatings, m_NumberOfFights, TAnimal::m_OurLandscape, Roe_Base::m_OurPopulation, RoeDeerInfo::m_Range_x, RoeDeerInfo::m_Range_y, Roe_Base::m_RangeCentre_x, Roe_Base::m_RangeCentre_y, Roe_Base::m_SearchRange, Roe_Base::m_Size, On_Expelled(), On_Rank(), Roe_Base::SupplyInfo(), RoeDeer_Population_Manager::SupplyTMales(), and Landscape::Warn().

Referenced by Step().

◆ MEvade()

int Roe_Male::MEvade ( )
protected

Roe_Male::MEvade - checks direction to threath and takes 50 steps in opposite direction. Returns to same state as before disturbance. Calls DirectionTo(), NextStep()

565 {
566  #ifdef JUJ__Debug3
567  if(IsAlive()!=0x0DEADC0DE)
568  {
569  m_OurLandscape ->Warn("Roe_Male::MEvade(): Deadcode warning!","");
570  exit( 1 );
571  }
572  #endif
573  m_MinInState[5]++; //add 1 to time spend in this state
574  int weight=3;
575  //get direction to threat
577  NextStep(weight,((dir+4) & 0x07),0);
578 
579  //return to same state as before disturbance
580  return m_LastState;
581 }
int m_danger_x
Definition: Roe_all.h:139
int m_danger_y
Definition: Roe_all.h:140

References Roe_Base::DirectionTo(), Roe_Base::IsAlive(), Roe_Base::m_danger_x, Roe_Base::m_danger_y, Roe_Base::m_LastState, TAnimal::m_Location_x, TAnimal::m_Location_y, m_MinInState, TAnimal::m_OurLandscape, Roe_Base::NextStep(), and Landscape::Warn().

Referenced by Step().

◆ MFeed()

int Roe_Male::MFeed ( void  )
protected

Roe_Male::MFeed - Models feeding of male object, including energy budget and search for better feeding area. Also determines need to ruminate. In theory a roe deer can spend time in more than 1 type of habitat within 1 timestep. For the energy budget only the habitat type where roe deer is at the beginning of each time step is recorded. Need to keep counter of minutes in feed since the end of last ruminating period (m_FeedCount) to know when to return to ruminate. Returns values for dispersal, ruminate or keep feeding (or die). Calls function NutriValue()

216 {
217  #ifdef JUJ__Debug3
218  if(IsAlive()!= 0x0DEADC0DE)
219  {
220  m_OurLandscape ->Warn("Roe_Male::MFeed(): Deadcode warning!","");
221  exit( 1 );
222  }
223  #endif
224  //In theory a roe can spend time in more than 1 type of habitat within 1 timestep.
225  //For the energy budget only the habitat type where roe is at the beginning of
226  //each time step is recorded. Need to keep counter of minutes
227  //in feed since the end of last ruminating period (m_FeedCount) to know when to
228  //return to ruminate
229  m_MinInState[10]++; //add 1 to time spend in this state
230  m_FeedCount++; //add 1 to count for this feeding bout
231  //allow roe the opportunity to return to this state after disturbance
232  m_LastState=36; //feed
233  //Find the nutritional value here
234  int nutri=NutriValue(m_Location_x,m_Location_y); //possible energy gain per minut
235  if (nutri<MinNutri) //not good enough for feeding
236  { //search for better place
239  }
240  else //can feed here
241  {
242  m_EnergyGained+=nutri; //add this to total count for today
244  }
245  //did roe die while taking feeding steps?
246  if (m_IsDead) //is dead
247  {
248  m_FeedCount=0;
249  return 42; //Die
250  }
251  else //still alive, so decide whereto next.
252  {
253  if (m_FeedCount>m_LengthFeedPeriod) //need to ruminate
254  {
255  //for how long do you need to ruminate?
256  int month= m_OurLandscape->SupplyMonth();
257  m_LengthRuminate=(int) (m_FeedCount*IntakeRate[month-1]*0.1);
258  m_FeedCount=0; //counter to zero
259  return 33; //ruminate
260  }
261  else if (m_Disperse==true) //a disperser, go back to disperse with 50:50 chance
262  //"Cheap" solution. No basis for setting this value. Return to this later....
263  {
264  int rand=random(100);
265  if (rand<50)
266  {
267  m_FeedCount=0;
268  return 11; //Disperse
269  }
270  }
271  }
272  return 36; //stay in feed
273 }
const int MinNutri
Definition: Roe_constants.cpp:62
const float IntakeRate[12]
Definition: Roe_constants.cpp:56
int m_LengthFeedPeriod
Definition: Roe_all.h:136
int NutriValue(int polyref)
int m_FeedCount
Definition: Roe_all.h:135
int Feeding(bool p_Disperse)
Definition: Roe_base.cpp:737
double m_EnergyGained
Definition: Roe_all.h:132
int m_LengthRuminate
Definition: Roe_all.h:137
void SeekNutri(int p_threshold)
Definition: Roe_base.cpp:197

References Roe_Base::Feeding(), IntakeRate, Roe_Base::IsAlive(), Roe_Base::m_Disperse, Roe_Base::m_EnergyGained, Roe_Base::m_FeedCount, Roe_Base::m_IsDead, Roe_Base::m_LastState, Roe_Base::m_LengthFeedPeriod, Roe_Base::m_LengthRuminate, TAnimal::m_Location_x, TAnimal::m_Location_y, m_MinInState, TAnimal::m_OurLandscape, MinNutri, Roe_Base::NutriValue(), random(), Roe_Base::SeekNutri(), Landscape::SupplyMonth(), and Landscape::Warn().

Referenced by Step().

◆ MFight()

int Roe_Male::MFight ( void  )
protected

Roe_Male::MFight -add 1 to time spend in this state and returns feeding state.

587 {
588  #ifdef JUJ__Debug3
589  if(IsAlive()!=0x0DEADC0DE)
590  {
591  m_OurLandscape ->Warn("Roe_Male::MFight(): Deadcode warning!","");
592  exit( 1 );
593  }
594  #endif
595  m_MinInState[7]++; //add 1 to time spend in this state
596  return 36; //MFeed
597 }

References Roe_Base::IsAlive(), m_MinInState, TAnimal::m_OurLandscape, and Landscape::Warn().

Referenced by Step().

◆ MIgnore()

int Roe_Male::MIgnore ( )
protected

Roe_Male::MIgnore - Ignore threath and adds 1 to time spend in this state. Return to same state as before disturbance

546 {
547  #ifdef JUJ__Debug3
548  if(IsAlive()!=0x0DEADC0DE)
549  {
550  m_OurLandscape ->Warn("Roe_Male::MIgnore(): Deadcode warning!","");
551  exit( 1 );
552  }
553  #endif
554  m_MinInState[6]++; //add 1 to time spend in this state
555  return m_LastState;
556 }

References Roe_Base::IsAlive(), Roe_Base::m_LastState, m_MinInState, TAnimal::m_OurLandscape, and Landscape::Warn().

Referenced by Step().

◆ MMate()

int Roe_Male::MMate ( void  )
protected

Roe_Male::MMate - add 1 to number of matings, stop attending female. Return to feed

829 {
830  #ifdef JUJ__Debug1
831  if(m_My_Mate==NULL)
832  {
833  m_OurLandscape ->Warn("Roe_Male::MMate: NULL pointer, m_My_Mate!","");
834  exit( 1 );
835  }
836  #endif
837  #ifdef JUJ__Debug3
838  if((IsAlive()!=0x0DEADC0DE)|| (m_My_Mate->IsAlive()!=0x0DEADC0DE))
839  {
840  m_OurLandscape ->Warn("Roe_Male::MMate(): Deadcode warning!","");
841  exit( 1 );
842  }
843  #endif
844  m_MinInState[11]++; //add 1 to time spend in this state
845  //add 1 to matings
846  m_NoOfMatings++;
847  //remove pointer to the female
848  m_My_Mate=NULL;
849  //last state must have been AttendFemale, so continue to Feed
850  return 36; //MFeed
851 }

References Roe_Base::IsAlive(), m_MinInState, m_My_Mate, m_NoOfMatings, TAnimal::m_OurLandscape, and Landscape::Warn().

Referenced by Step().

◆ MOnMature()

int Roe_Male::MOnMature ( void  )
protected

Roe_Male::MOnMature - Checks if area is good enough to establish range. The function ScanGrid() adds the quality values stored in m_grid starting with a minimum area of 400 x 400 m. If not sufficient it extends outwards in all directions until max range is reached (800 x 800 m). It also checks if amount of other males nearby is below a male density threshold. It returns the size of the resulting area if good enough and 0 if not good enough Calls ScanGrid(), SupplyMaleRC().

33 {
34  #ifdef JUJ__Debug3
35  if(IsAlive()!=0x0DEADC0DE)
36  {
37  m_OurLandscape ->Warn("Roe_Male::MOnMature(): Deadcode warning!","");
38  exit( 1 );
39  }
40  #endif
41 
42  //Check whether this area is good enough. The function ScanGrid()
43  //adds the quality values stored in m_grid starting with a minimum area of
44  //400 x 400 m. If not sufficient it extends outwards in all directions
45  //until max range is reached (800 x 800 m). It returns the size of the
46  //resulting area if good enough and 0 if not good enough
47 
49  if (range > 0) //good enough
50  {
51  //how many other males already in area?
53  SupplyMaleRC(m_Location_x,m_Location_y,range);
54  if(males->size() < MaleDensityThreshold) //OK
55  {
56  m_SearchRange = range;
57  delete males;
58  return 8; // establish range
59  }
60  delete males;
61  }
62  return 11; //no options in this area, so disperse
63 }
const unsigned MaleDensityThreshold
Definition: Roe_constants.cpp:29
int ScanGrid(int p_x, int p_y, bool avq)
Definition: Roe_Population_Manager.cpp:280

References Roe_Base::IsAlive(), TAnimal::m_Location_x, TAnimal::m_Location_y, TAnimal::m_OurLandscape, Roe_Base::m_OurPopulation, Roe_Base::m_SearchRange, MaleDensityThreshold, RoeDeer_Population_Manager::ScanGrid(), and Landscape::Warn().

Referenced by Step().

◆ MOnNewDay()

int Roe_Male::MOnNewDay ( void  )
protected

Roe_Male::MOnNewDay - updates age of male object (+ 1 day), decides if life expectancy has been reached, which depends on age (Floaters have a higher mortality (added FloatMort)). Checks whether dispersers and floaters can set up range by checking habitat, closeness to mothers range and amount of males already in the area. If failed to find a range before october 1st become a floater. Also governs establishement of territory dependent on age. Returns values to set the following states: establish range, establish territory, mate, update energy (and die). Calls functions DistanceTo(), ScanGrid(), SupplyMaleRC().

648 {
649  #ifdef JUJ__Debug3
650  if(IsAlive()!=0x0DEADC0DE)
651  {
652  m_OurLandscape ->Warn("Roe_Male::MOnNewDay(): Deadcode warning!","");
653  exit( 1 );
654  }
655  #endif
656  m_Age++; //1 day older
657 
658  m_DestinationDecided=false; //don't know yet whereto after this
659  m_NewState=0;
660  int dist;
661  int mort;
662  //First decide if life expectancy has been reached. Depends on age. Floaters
663  //have a higher mortality (added FloatMort)
664 
665  long int die=random(100000); //since mort rates are multiplied with 100000 to
666  //produce int values
667  if (m_Age<=730)
668  mort=(int)MaleDMR[0]; //age in days
669  else if (m_Age<=2555) //7 yrs
670  mort=(int)MaleDMR[1];
671  else if (m_Age<=3650) //10 yrs
672  mort=(int)MaleDMR[2];
673  else mort =(int)MaleDMR[3]; //>10 yrs, 90 % mortality
674 
675  if((m_float)||(m_Disperse)) mort += FloatMort;
676  if (die<mort)
677  {
678  return 42; //MDie
679  }
680  else //still alive
681  {
682  // 1: DISPERSAL
683  if(m_Disperse)
684  {
685  if(!m_float)
686  {
687  //get distance to mothers RangeCentre
689  }
690  else
691  { //floaters check distance beck to last failed attempt to set up range
693  }
694  if (dist>MinDispDistance) //check if this is good spot to set up range
695  {
696  //both floaters and regular dispersers go in here
697  bool found = false;
699  if (range > 0) //OK
700  {
701  //how many other males have already their range in this area?
703  if(males->size() < MaleDensityThreshold) //OK
704  {
705  m_SearchRange=range;
707  found=true;
708  m_NewState= 8; // establish range
709  }
710  delete males;
711  }
712  if(!found) //quality too poor or still too close to mother, so return to disperse
713  {
714  //if failed to find a range before october 1st become a floater
716  { //floaters store present position for use in next attempt to set up range
719  m_float=true;
720  }
722  m_NewState=11; //MDisperse
723  }
724  }
725  }
726  if(m_Age>=730) //can attempt to establish territory
727  {
728  if ((m_HaveTerritory==false)&&(m_HaveRange==true))
729 
730  {
732  m_NewState=9; //MEstablish territory
733  }
734  }
735  if(m_My_Mate!=NULL) //is attending female
736  {
737  return 40; //mate
738  }
739  }
740  return 5; //MUpdateEnergy
741 }
const int MinDispDistance
Definition: Roe_constants.cpp:24
const int FloatMort
Definition: Roe_constants.cpp:133
const float MaleDMR[4]
Definition: Roe_constants.cpp:137
int SupplyDayInYear(void)
Definition: landscape.h:1596
int m_float_x
Definition: Roe_all.h:240
int m_NewState
Definition: Roe_all.h:238
bool m_DestinationDecided
Definition: Roe_all.h:237
int m_float_y
Definition: Roe_all.h:241
ListOfMales * SupplyMaleRC(int p_x, int p_y, int SearchRange)
Definition: Roe_Population_Manager.cpp:1185

References Roe_Base::DistanceTo(), FloatMort, Roe_Base::IsAlive(), Roe_Base::m_Age, Roe_Adult_Base::m_DestinationDecided, Roe_Base::m_Disperse, Roe_Base::m_float, Roe_Adult_Base::m_float_x, Roe_Adult_Base::m_float_y, Roe_Base::m_HaveRange, m_HaveTerritory, TAnimal::m_Location_x, TAnimal::m_Location_y, m_My_Mate, Roe_Adult_Base::m_NewState, Roe_Base::m_OldRange_x, Roe_Base::m_OldRange_y, TAnimal::m_OurLandscape, Roe_Base::m_OurPopulation, Roe_Base::m_SearchRange, MaleDensityThreshold, MaleDMR, MinDispDistance, random(), RoeDeer_Population_Manager::ScanGrid(), Landscape::SupplyDayInYear(), RoeDeer_Population_Manager::SupplyMaleRC(), and Landscape::Warn().

Referenced by Step().

◆ MRecover()

int Roe_Male::MRecover ( void  )
protected

Roe_Male::MRecover - Governs recovery after running from danger. Function counts amount of time in state during the present period of recovovery (m_RecovCount) and sets this to 0 when state is left. Female only transfers to this state if safe, whichs means in good habitat. Returns states: feeding, recovery.

465 {
466  #ifdef JUJ__Debug3
467  if(IsAlive()!=0x0DEADC0DE)
468  {
469  m_OurLandscape ->Warn("Roe_Male::MRecover(): Deadcode warning!","");
470  exit( 1 );
471  }
472  #endif
473  //Need to count amount of time in state during the present
474  //period of recov. (m_RecovCount) and set this to 0 when state is left.
475  //Roe only transfers to this state if safe (i.e. cover>=3) so we know it is in
476  //good habitat
477  m_MinInState[4]++; //add 1 to time spend in this state
478 
479  //allow roe the opportunity to return to this state after disturbance
480  m_LastState=23; //recover
482  {
483  m_RecovCount++; //add 1 to time spend in recover and stay here
484  return 23; //recover
485  }
487  //return to feed with certain probability
488  {
489  int stop= random(100);
490  if (stop<10)
491  {
492  m_RecovCount=0; //leaves state, so set counter=0
493  m_FeedCount=0; //ruminating also takes place during recovery, so start
494  //from scratch in Feed
495  return 36; //feed
496  }
497  else
498  {
499  m_RecovCount++; //add 1 to time spend in this state
500  return 23; //recover
501  }
502  }
503  else //if still around after this long return to feeding
504  {
505  m_RecovCount=0;
506  return 36;
507  }
508 }
const int MaxRecoveryTime
Definition: Roe_constants.cpp:39
const int AverageRecoveryTime
Definition: Roe_constants.cpp:38
int m_RecovCount
Definition: Roe_all.h:133

References AverageRecoveryTime, Roe_Base::IsAlive(), Roe_Base::m_FeedCount, Roe_Base::m_LastState, m_MinInState, TAnimal::m_OurLandscape, Roe_Base::m_RecovCount, MaxRecoveryTime, random(), and Landscape::Warn().

Referenced by Step().

◆ MRuminate()

int Roe_Male::MRuminate ( void  )
protected

Roe_Male::MRuminate - Function for ruminating. Checks for got spot to rest and amount of time spent ruminating. Ruminate activity cannot be seperated from other kinds of inactivity. It is also assumed that ruminating takes place while recovering after disturbance. Need to count amount of time spend in this state during this period of ruminating and in total last 24 hrs. Returns values for either stay ruminating, feed or dispersal (or die).Calls function Cover().

383 {
384  #ifdef JUJ__Debug3
385  if(IsAlive()!=0x0DEADC0DE)
386  {
387  m_OurLandscape ->Warn("Roe_Male::MRuminate(): Deadcode warning!","");
388  exit( 1 );
389  }
390  #endif
391  //ruminate activity cannot be seperated from other kinds of inactivity.
392  //It is also assumed that ruminating takes place while recovering after
393  //disturbance. Need to count amount of time spend in this state during
394  //this period of ruminating and in total last 24 hrs
395  m_MinInState[9]++; //add 1 to time spend in this state
396  int min;
397  //First check if this is first timestep in this state
398  //allow roe the opportunity to return to this state after disturbance
399  m_LastState=33;
400  if (m_RumiCount==0) //first step so make sure this is a good spot to rest
401  {
402  int cover=Cover(m_Location_x,m_Location_y);
403  //get month
404  int month=m_OurLandscape->SupplyMonth();
405  if((month>=5)&&(month<=9)) min=CoverThreshold2; //summer
406  else min=CoverThreshold1; //winter
407  if (cover<min)// habitat unsuitable or cover very poor, so look for better spot
408  {
409  SeekCover(2);
410  if(m_IsDead) return 42; //Die
411  else
412  {
413  m_RumiCount++;
414  return 33;
415  }
416  }
417  else //cover OK
418  {
419  m_RumiCount++; //add 1 to counter
420  return 33; //return to this state next time step
421  }
422  }
424  {
425  m_RumiCount++; //add to counter
426  return 33; //stay
427  }
428  else
429  {
430  if(m_Disperse==true) return 11;
431  else //not disperser
432  {
434  {
435  m_RumiCount=0;
436  return 36; //feed
437  }
438  else
439  {
440  int rand = random(100);
441  if(rand<50)
442  {
443  m_RumiCount++;
444  return 33; //stay
445  }
446  else
447  {
448  m_RumiCount=0;
449  return 36;
450  }
451  }
452  }
453  }
454 }
const int CoverThreshold2
Definition: Roe_constants.cpp:41
const int CoverThreshold1
Definition: Roe_constants.cpp:40
void SeekCover(int threshold)
Definition: Roe_base.cpp:42
int Cover(int polyref)
Calls the cover calculation for a given polyref.
Definition: Roe_base.cpp:943
int m_RumiCount
Definition: Roe_all.h:134

References Roe_Base::Cover(), CoverThreshold1, CoverThreshold2, Roe_Base::IsAlive(), Roe_Base::m_Disperse, Roe_Base::m_IsDead, Roe_Base::m_LastState, Roe_Base::m_LengthRuminate, TAnimal::m_Location_x, TAnimal::m_Location_y, m_MinInState, TAnimal::m_OurLandscape, Roe_Base::m_RumiCount, random(), Roe_Base::SeekCover(), Landscape::SupplyMonth(), and Landscape::Warn().

Referenced by Step().

◆ MRun()

int Roe_Male::MRun ( )
protected

Roe_Male::MRun - Sets the male object to be in a running state - and checks if safe after 1 time step in this state. Calls Running().

517 {
518  #ifdef JUJ__Debug3
519  if(IsAlive()!=0x0DEADC0DE)
520  {
521  m_OurLandscape ->Warn("Roe_Male::MRun(): Deadcode warning!","");
522  exit( 1 );
523  }
524  #endif
525 
526  m_MinInState[3]++; //add 1 to time spend in this state
527  bool IsSafe=Running(m_danger_x,m_danger_y);
528  if(m_IsDead) return 42; //Die
529  else if (!IsSafe) //still not safe after 1 time step
530  {
531  return 20;
532  }
533  else
534  {
535  m_RecovCount++; //add 1 to time spend in recovery
536  return 23; //safe
537  }
538 }
bool Running(int x, int y)
Definition: Roe_base.cpp:380

References Roe_Base::IsAlive(), Roe_Base::m_danger_x, Roe_Base::m_danger_y, Roe_Base::m_IsDead, m_MinInState, TAnimal::m_OurLandscape, Roe_Base::m_RecovCount, Roe_Base::Running(), and Landscape::Warn().

Referenced by Step().

◆ MUpdateEnergy()

int Roe_Male::MUpdateEnergy ( void  )
protected

Roe_Male::MUpdateEnergy - Calculates how much energy is used (in cal/minute) in different activities. Calculates net energy (gained-used) and determines whether excess enery is added to reserves or is used to put on weight. A negative net energy causes the male object to loose weight - if roe deer weight falls below a minimum value, the deer will die. If the roe deer is in very bad condition, forage time is increased. returns states such as mate, feed, newState or die.

752 {
753  #ifdef JUJ__Debug3
754  if(IsAlive()!=0x0DEADC0DE)
755  {
756  m_OurLandscape ->Warn("Roe_Male::MUpdateEnergy(): Deadcode warning!","");
757  exit( 1 );
758  }
759  #endif
760  //All energetic calculations in cal/minute!
761  //Calculate how much energy used in different activities
762  double EnergyUsed=0;
763  int month=m_OurLandscape->SupplyMonth();
764  for (int i=0; i<12; i++)
765  {
766  double cost;
767  if (CostMaleAct[i]==1) cost=CostMaleAct[i]*MaleRMR; //rest activity
768  else cost=(double) CostMaleAct[i];
769  EnergyUsed += double ((cost * m_MinInState[i] * (m_Size*0.001)));
770  }
771  double result = m_EnergyGained - EnergyUsed; //in cal
772  if (result>0)
773  {
774  if (m_Reserves <= 10) m_Reserves++; //add to reserves
775  else
776  {
777  m_Size += (int)floor(result * Anabolic_Inv); //put on weight
778  }
779  }
780  else if (result<0)
781  {
782  if (m_Reserves > 0) m_Reserves--;
783  else
784  {
785  m_Size += (int)floor(result*Catabolic_Inv); //loose weight
786  }
787  }
788 
789  //Update m_Size. If m_Size < MinSize roe dies
790 
792  {
793  return 42; //MDie
794  }
796  {
797  //in very bad condition, need to increase forage time
798  m_LengthFeedPeriod = (int)((5*m_Size*0.001)/Male_FeedBouts[month-1]);
799  }
800  else
801  {
802  m_LengthFeedPeriod = (int)((2.3*m_Size*0.001)/
803  Male_FeedBouts[month-1]);
805  }
806  //set counter of daily energy gain to zero
807  m_EnergyGained=0;
808  for(int i=0;i<12;i++)
809  {
810  m_MinInState[i]=0;
811  }
812  //if LastState was AttendFemale, go to mate
813  if (m_LastState==31)
814  {
815  return 40; //Mate
816  }
817  else if (m_NewState!=0) //otherwise it's directed to m_NewState
818  {
819  return m_NewState;
820  }
821  else return 36; //feed
822 }
const float MaleRMR
Definition: Roe_constants.cpp:76
const float Catabolic_Inv
Definition: Roe_constants.cpp:123
const int CostMaleAct[12]
Definition: Roe_constants.cpp:109
const float Anabolic_Inv
Definition: Roe_constants.cpp:120
const int Male_FeedBouts[12]
Definition: Roe_constants.cpp:87
int m_CriticalWeight_Males
Definition: Roe_all.h:510
int m_MinWeight_Males
Definition: Roe_all.h:508

References Anabolic_Inv, Catabolic_Inv, CostMaleAct, Roe_Base::IsAlive(), RoeDeer_Population_Manager::m_CriticalWeight_Males, Roe_Base::m_EnergyGained, Roe_Base::m_LastState, Roe_Base::m_LengthFeedPeriod, m_MinInState, RoeDeer_Population_Manager::m_MinWeight_Males, Roe_Adult_Base::m_NewState, TAnimal::m_OurLandscape, Roe_Base::m_OurPopulation, Roe_Base::m_Reserves, Roe_Base::m_Size, Male_FeedBouts, MaleRMR, Landscape::SupplyMonth(), and Landscape::Warn().

Referenced by Step().

◆ On_ApproachOfDanger()

void Roe_Male::On_ApproachOfDanger ( int  p_To_x,
int  p_To_y 
)

Roe_Male::On_ApproachOfDanger - Determines whether to run or evade a threat depending on cover and distance to threath. In good cover, male will run if threath is less than 30 m away and else perform evasive behavior, In intermediate cover the flight distance is 50 m, and in poor cover it is 70 m. Returns states evade or run. Calls Cover(), DistanceTo().

1454 {
1455  m_danger_x=p_To_x;
1456  m_danger_y=p_To_y;
1457  //get cover
1458  int cov=Cover(m_Location_x,m_Location_y);
1459  //get distance to threat
1460  int dist=DistanceTo(m_Location_x, m_Location_y,p_To_x,p_To_y);
1461 
1462  if (cov >= CoverThreshold2) //good cover
1463  {
1464  if(dist >= 30)
1465  {
1467  }
1468  else CurrentRState=rds_MRun;
1469  }
1470  else if (cov >= CoverThreshold1) //intermediate cover
1471  {
1472  if(dist>=50)
1473  {
1475  }
1476  else CurrentRState=rds_MRun;
1477  }
1478  else //poor cover
1479  {
1480  if(dist>=70)
1481  {
1483  }
1484  else CurrentRState=rds_MRun;
1485  }
1486 }
@ rds_MRun
Definition: Roe_all.h:66

References Roe_Base::Cover(), CoverThreshold1, CoverThreshold2, Roe_Base::CurrentRState, Roe_Base::DistanceTo(), Roe_Base::m_danger_x, Roe_Base::m_danger_y, TAnimal::m_Location_x, TAnimal::m_Location_y, rds_MEvade, and rds_MRun.

◆ On_Expelled()

void Roe_Male::On_Expelled ( Roe_Male rival)

Following the On_Rank() function - if a male territory holder loses a fight and gets expelled from his territory. Clears satellite list, sets object to be a floater and current state to dispersal Calls OnNewHost().

1895 {
1896  #ifdef JUJ__Debug3
1897  if(rival->IsAlive()!=0x0DEADC0DE)
1898  {
1899  m_OurLandscape ->Warn("Roe_Male::On_Expelled():Deadcode warning, rival!","");
1900  exit( 1 );
1901  }
1902  #endif
1903  //for the moment floaters are just send dispersing, they can establish new range
1904  //somewhere else.
1905  //remove pointers to any satellite males
1906 
1907  for(unsigned i=0;i<50;i++)
1908  {
1909  if(m_MySatellites[i]!=NULL)
1910  {
1911  #ifdef JUJ__Debug3
1912  if(m_MySatellites[i]->IsAlive()!=0x0DEADC0DE)
1913  {
1914  m_OurLandscape ->Warn("Roe_Male::On_Expelled():Deadcode warning,m_Mysatellites!","");
1915  exit( 1 );
1916  }
1917  #endif
1918  if(m_MySatellites[i]!=rival)
1919  {
1920  m_MySatellites[i]->On_NewHost(rival); //they add themselves to the new list
1921  }
1922 
1923  m_MySatellites[i]=NULL; //set all to NULL including rival
1924  }
1925  }
1926  m_float=true;
1929  CurrentRState=rds_MDisperse; //floater
1930 }
@ rds_MDisperse
Definition: Roe_all.h:57
void On_NewHost(Roe_Male *host)
Definition: Roe_male.cpp:1937

References Roe_Base::CurrentRState, Roe_Base::IsAlive(), Roe_Base::m_float, Roe_Adult_Base::m_float_x, Roe_Adult_Base::m_float_y, TAnimal::m_Location_x, TAnimal::m_Location_y, m_MySatellites, TAnimal::m_OurLandscape, On_NewHost(), rds_MDisperse, and Landscape::Warn().

Referenced by MEstablishTerritory(), and On_Rank().

◆ On_InHeat()

bool Roe_Male::On_InHeat ( Roe_Female female,
int  p_x,
int  p_y 
)

Roe_Male::On_InHeat - response of male object to "In Heat" message sent by female object. Check if already have mate and if not check if distance to female is too large. If not too large, the male checks for rivals around, checks rank (also dependent on whether he is in his own territory), challenges them and adds them to fightlist. If the male wins, he will attend the female otherwise he will give up attending this female. Calls SupplyTMales(), DistanceTo(), On_Rank(), AddToFightList().

1637 {
1638  #ifdef JUJ__Debug3
1639  if((IsAlive()!= 0x0DEADC0DE)||(female->IsAlive()!= 0x0DEADC0DE))
1640  {
1641  m_OurLandscape ->Warn("Roe_Male::On_InHeat():Deadcode warning!","");
1642  exit( 1 );
1643  }
1644  #endif
1645  //want to attend this female if not attending one already
1646  if (m_My_Mate == NULL)
1647  {
1648  WalkTo(p_x,p_y);
1649  int dist = DistanceTo(m_Location_x,m_Location_y,p_x,p_y);
1650  if (dist < 50) //close enough to female,
1651  //now find out if there are potential rivals around
1652  {
1654  m_Location_y,100);
1655  bool home=false;
1656  bool rank=true; //initiated to true and only altered if there are stronger rivals
1657  //are you still in your own territory?
1660  {
1661  home=true; //yes
1662  }
1663 
1664  for(unsigned i=0;i<Tmales->size();i++) //foe every male in area
1665  {
1666  m_NumberOfFights++;
1667  //challenge him and add him to fightlist
1668  rank=(*Tmales)[i]->On_Rank(this,(double) m_Size, m_Age, m_NoOfMatings,home,false);
1670  if (rank==false) break; //lost...give up attending this female
1671  }
1672  if (rank==true)
1673  {
1674  #ifdef JUJ__Debug1
1675  if(female==NULL)
1676  {
1677  m_OurLandscape ->Warn("Roe_Male::On_InHeat():NULL pointer, female!","");
1678  exit( 1 );
1679  }
1680  #endif
1681 
1682  m_My_Mate = female;
1683  CurrentRState=rds_MAttendFemale; //attend female
1684  }
1685  delete Tmales;
1686  return rank; //also returns true if no rivals around
1687  }
1688  else return false; //still too far away
1689  }
1690  else return false; //will not attend
1691 }
@ rds_MAttendFemale
Definition: Roe_all.h:77

References RoeDeer_Population_Manager::AddToFightlist(), Roe_Base::CurrentRState, Roe_Base::DistanceTo(), Roe_Base::IsAlive(), Roe_Base::m_Age, TAnimal::m_Location_x, TAnimal::m_Location_y, m_My_Mate, m_MyFightlist, m_NoOfMatings, m_NumberOfFights, TAnimal::m_OurLandscape, Roe_Base::m_OurPopulation, Roe_Base::m_RangeCentre_x, Roe_Base::m_RangeCentre_y, Roe_Base::m_Size, rds_MAttendFemale, RoeDeer_Population_Manager::SupplyTMales(), Roe_Base::WalkTo(), and Landscape::Warn().

◆ On_IsDead()

void Roe_Male::On_IsDead ( Roe_Base Base,
int  whos_dead,
bool  fawn 
)
virtual

Roe_Male::On_IsDead - governs a male objects "response" to death of another object. Checks who is dead (mom, male, mate) and sets them to NULL. If a male object is dead, the "responding" male object checks if dead object is host ("responding" object is satellite male). If so it will send message to the dead host's other satellites. Rank is checked among satellites and if "responding" male wins a fight, he will take over territory of dead male. If the dead object is a satellite of the "responding" male, it will be removed from satellite list. If dead object holds a territory and "responding" male is not a satellite to the dead object but is also not a territory holder, he can challenge nearby interested males (also without territory) and win territory. Herefter if satellite to another host, the "responding" male will send a message and remove itself from satellite list. If dead object is the "responding" male's mate, the "responding" male will seize to attend the female. Calls On-Rank(), SupplyInfo(), SupplyMales(), RemoveSatellites().

Reimplemented from Roe_Base.

1505 {
1506  #ifdef JUJ__Debug3
1507  if((IsAlive()!= 0x0DEADC0DE)||(Base->IsAlive()!= 0x0DEADC0DE))
1508  {
1509  m_OurLandscape ->Warn("Roe_Male::On_IsDead():Deadcode warning!","");
1510  exit( 1 );
1511  }
1512  #endif
1513  Roe_Male* male;
1514  ListOfMales* rivals;
1515  RoeDeerInfo info;
1516  bool rank=true;
1517  bool found=false;
1518  //whos_dead: 0=mum 1=other male, 2=mate
1519  switch(whos_dead)
1520  {
1521  case 0: //mum
1522  if(Base!=Mum)
1523  {
1524  m_OurLandscape ->Warn("Roe_Male::On_IsDead():Bad pointer, Base!","");
1525  exit( 1 );
1526  }
1527  else Mum=NULL;
1528  break;
1529  case 1: //a male is dead, check if he is your host
1530  if (Base==m_MyTMale)
1531  {
1532  for(unsigned i=0;i<50;i++) //
1533  { //send message to any other satellites
1534  if(m_MyTMale->m_MySatellites[i]!=NULL)
1535  {
1536  #ifdef JUJ__Debug3
1537  if(m_MyTMale->m_MySatellites[i]->IsAlive()!= 0x0DEADC0DE)
1538  {
1539  m_OurLandscape ->Warn("Roe_Male::On_IsDead():Deadcode warning, m_MySatellites!","");
1540  exit( 1 );
1541  }
1542  #endif
1543  rank=m_MyTMale->m_MySatellites[i]->
1544  On_Rank(this,(double) m_Size,m_Age,m_NoOfMatings,true,false);
1545  }
1546  if (rank==false) break; //lost
1547  }
1548  if(rank==true) //take this territory
1549  {
1550  m_HaveTerritory=true;
1551  m_Disperse=false;
1552  m_DispCount=0;
1553  m_MinInState[1] += 1;
1554  }
1555  m_MyTMale=NULL; //delete pointer
1556  }
1557  else //dead male is not your host
1558  {
1559  //first check if he is one of your satellites
1560  for(unsigned i=0;i<50;i++)
1561  {
1562  if(m_MySatellites[i]==Base)
1563  {
1564  m_MySatellites[i]=NULL;
1565  found=true;
1566  break;
1567  }
1568  }
1569  if(found==false) //not a satellite male
1570  {
1571  male=dynamic_cast<Roe_Male*> (Base);
1572  info=male->SupplyInfo();
1573  //If he is a territory holder and you're not, you can try to take over
1574  if((m_HaveTerritory==false)&&(male->SupplyHaveTerritory()==true))
1575  {
1576  //charge other males in the area, who might be interested
1578  for(unsigned i=0;i<rivals->size();i++)
1579  {
1580  #ifdef JUJ__Debug3
1581  if ((*rivals)[i]->IsAlive()!= 0x0DEADC0DE)
1582  {
1583  m_OurLandscape ->Warn("Roe_Male::On_IsDead():Deadcode warning, (*rivales)[i]!","");
1584  exit( 1 );
1585  }
1586  #endif
1587  if((*rivals)[i]!=Base) //no point in challenging the dead male
1588  {
1589  rank=(*rivals)[i]->On_Rank(this,(double) m_Size,m_Age,
1590  m_NoOfMatings,false,false);
1591  }
1592  if (rank==false) break; //lost, at least 1 male is interested and stronger than you
1593  }
1594  delete rivals;
1595  if(rank==true) //won, can take over
1596  {
1597  m_HaveTerritory=true;
1598  m_Disperse=false;
1599  m_DispCount=0;
1600  m_MinInState[1] += 1;
1603  if(m_MyTMale!=NULL) //you have a host, so tell him
1604  {
1605  m_MyTMale->RemoveSatellite(this);
1606  m_MyTMale=NULL;
1607  }
1608  }
1609  }
1610  }
1611  }
1612  break;
1613 
1614  case 2://sender is your mate
1615  m_My_Mate=NULL;
1616  //give up attending female
1618  break;
1619 
1620  default:
1621  m_OurLandscape ->Warn("Roe_Male::On_IsDead():No matching case!","");
1622  exit( 1 );
1623  } //end of switch
1624 }
@ rds_MFeed
Definition: Roe_all.h:82
Definition: Roe_all.h:380
bool SupplyHaveTerritory()
Definition: Roe_all.h:420

References Roe_Base::CurrentRState, Roe_Base::IsAlive(), Roe_Base::m_Age, Roe_Adult_Base::m_DispCount, Roe_Base::m_Disperse, m_HaveTerritory, m_MinInState, m_My_Mate, m_MySatellites, m_MyTMale, m_NoOfMatings, TAnimal::m_OurLandscape, Roe_Base::m_OurPopulation, RoeDeerInfo::m_Range_x, RoeDeerInfo::m_Range_y, Roe_Base::m_RangeCentre_x, Roe_Base::m_RangeCentre_y, Roe_Base::m_SearchRange, Roe_Base::m_Size, Roe_Base::Mum, On_Rank(), rds_MFeed, RemoveSatellite(), SupplyHaveTerritory(), Roe_Base::SupplyInfo(), RoeDeer_Population_Manager::SupplyMales(), and Landscape::Warn().

Referenced by Roe_Female::FDie(), and MDie().

◆ On_NewHost()

void Roe_Male::On_NewHost ( Roe_Male host)

Roe_Male::On_NewHost - assigns new host to satellite male by adding satellite to host's satellite list and setting host to new host. Calls AddSatellite().

1938 {
1939  #ifdef JUJ__Debug3
1940  if(IsAlive()!=0x0DEADC0DE)
1941  {
1942  m_OurLandscape ->Warn("Roe_Male::On_NewHost():Deadcode warning!","");
1943  exit( 1 );
1944  }
1945  #endif
1946  //you have got a new host, the territory attributes stays the same
1947  m_MyTMale=host;
1948  m_MyTMale->AddSatellite(this); //tell him to add you to his list
1949 }

References AddSatellite(), Roe_Base::IsAlive(), m_MyTMale, TAnimal::m_OurLandscape, and Landscape::Warn().

Referenced by On_Expelled().

◆ On_Rank()

bool Roe_Male::On_Rank ( Roe_Male rival,
double  size,
int  age,
int  matings,
bool  where,
bool  range 
)

Roe_Male::On_Rank is used to establish ranks between male object and rival male object. The rank is dependent on male size, age, whether the males is in his own territory, number of previous matings,and number of previous fights. It also checks for location (if in adversarys territory, winning male can expell territory holder - and call On_Expelled()). If male object is taking over a territory from a rival male, the male object will receive the rival's list of satllite males. Calls AddToFightlist(), DistanceTo(), SupplyInfor(), On_Expelled(), RemoveSatellite().

1774 {
1775  int MyScore=0;
1776  int HisScore=0;
1777  bool outcome = true;
1778  m_NumberOfFights++;
1779  m_MinInState[7]++;
1780 
1781  //add rival to your fightlist
1783 
1784  //Establish rank:
1785  //size
1786  if(m_Size>size) MyScore++;
1787  else if (size>m_Size) HisScore++;
1788  else
1789  {
1790  MyScore++;
1791  HisScore++;
1792  }
1793  //age
1794  if (m_Age==age)
1795  {
1796  MyScore++;
1797  HisScore++;
1798  }
1799  else
1800  {
1801  if ((m_Age<=MalePrime)&&(age<=MalePrime)) //both young
1802  {
1803  if (m_Age>age) MyScore++; //advantage to older roe
1804  else HisScore++;
1805  }
1806  else if ((m_Age>MalePrime)&&(age>MalePrime)) //both old
1807  {
1808  if (m_Age>age) HisScore++;
1809  else MyScore++;
1810  }
1811  else if ((m_Age>MalePrime)&&(age<=MalePrime)) HisScore++;
1812  else MyScore++;
1813  }
1814  //matings
1815  if (m_NoOfMatings==matings)
1816  {
1817  MyScore++;
1818  HisScore++;
1819  }
1820  else
1821  {
1822  if (m_NoOfMatings>matings) MyScore++;
1823  else HisScore++;
1824  }
1825  //where are we
1826  //first check if you are in own territory (< 400 m from rangecentre)
1827  bool home=false;
1829  &&(!m_float))
1830  {
1831  home=true;
1832  }
1833  if ((home==true)&&(where==true)) //in overlap area
1834  {
1835  MyScore++;
1836  HisScore++;
1837  }
1838  else //one or both are false
1839  {
1840  if (home==true) MyScore++;
1841  else if (where==true) HisScore++;
1842  }
1843  //now sum up score
1844  if (MyScore==HisScore) //random outcome
1845  {
1846  int rand=random(100);
1847  if(rand<50) //I win
1848  {
1849  outcome=false;
1850  }
1851  else outcome=true; //rival wins
1852  }
1853  else if (MyScore>HisScore)
1854  {
1855  outcome=false; //I win
1856  //if this is a territory fight, I can expell him from his territory if I want to
1857  if ((range==true)&&(m_HaveTerritory==false))
1858  {
1859  #ifdef JUJ__Debug1
1860  if(rival==NULL)
1861  {
1862  m_OurLandscape ->Warn("Roe_Male::On_Rank():NULL pointer, rival!","");
1863  exit( 1 );
1864  }
1865  #endif
1866  //rival tells his other satellites to add themselves
1867  //to your list. You just need to delete pointer
1868  if(m_MyTMale!=NULL)
1869  {
1870  m_MyTMale->RemoveSatellite(this);
1871  m_MyTMale=NULL;
1872  }
1873  rival->On_Expelled(this);
1874  RoeDeerInfo info=rival->SupplyInfo();
1877  m_HaveTerritory=true;
1878  m_HaveRange=true;
1879  m_Disperse=false;
1880  m_DispCount=0;
1881  m_float=false;
1882  }
1883  }
1884  else outcome=true; //rival wins
1885  return outcome;
1886 }
const int MalePrime
Definition: Roe_constants.cpp:152

References RoeDeer_Population_Manager::AddToFightlist(), Roe_Base::DistanceTo(), Roe_Base::m_Age, Roe_Adult_Base::m_DispCount, Roe_Base::m_Disperse, Roe_Base::m_float, Roe_Base::m_HaveRange, m_HaveTerritory, TAnimal::m_Location_x, TAnimal::m_Location_y, m_MinInState, m_MyFightlist, m_MyTMale, m_NoOfMatings, m_NumberOfFights, TAnimal::m_OurLandscape, Roe_Base::m_OurPopulation, RoeDeerInfo::m_Range_x, RoeDeerInfo::m_Range_y, Roe_Base::m_RangeCentre_x, Roe_Base::m_RangeCentre_y, Roe_Base::m_Size, MalePrime, On_Expelled(), random(), RemoveSatellite(), Roe_Base::SupplyInfo(), and Landscape::Warn().

Referenced by MEstablishTerritory(), and On_IsDead().

◆ RemoveSatellite()

void Roe_Male::RemoveSatellite ( Roe_Male sat)

Roe_Male::RemoveSatellite - clears the list of satellite males that belongs to a male object

1728 {
1729  #ifdef JUJ__Debug3
1730  if(sat->IsAlive()!=0x0DEADC0DE)
1731  {
1732  m_OurLandscape ->Warn("Roe_Male::RemoveSatellite():Deadcode warning, sat!","");
1733  exit( 1 );
1734  }
1735  #endif
1736  bool found=false;
1737  //remove satellite male from your list
1738  for(unsigned i=0;i<50;i++)
1739  {
1740  if(m_MySatellites[i]==sat)
1741  {
1742  m_MySatellites[i]=NULL;
1743  found=true;
1744  break;
1745  }
1746  }
1747  if(found==false)
1748  {
1749  m_OurLandscape ->Warn("Roe_Male::RemoveSatellite():satellite not found!","");
1750  exit( 1 );
1751  }
1752 }

References Roe_Base::IsAlive(), m_MySatellites, TAnimal::m_OurLandscape, and Landscape::Warn().

Referenced by MDisperse(), On_IsDead(), and On_Rank().

◆ Step()

void Roe_Male::Step ( void  )
virtual

Roe_Male::Step - function called every time step. The functions checks if done with a given state (m_StepDone) and governs states and transitions to other states. Calls functions: MOnMature(), MDie(), MOnNewDay(), MMate(), MEstablishRange(), MEstablishTerritory(), MDisperse(), MFeed(), MRecover(), MRUn(), MEvade(), MIgnore(), MRuminate(), MFight(), MAttendFemale(), MUpdateEnergy()

Reimplemented from Roe_Adult_Base.

1036 {
1037  #ifdef JUJ__Debug3
1038  if(IsAlive()!=0x0DEADC0DE)
1039  {
1040  m_OurLandscape ->Warn("Roe_Male::Step(): Deadcode warning!","");
1041  exit( 1 );
1042  }
1043  #endif
1044 
1045  if (m_StepDone || (CurrentRState == rds_MDeathState)) return;
1046 
1047  switch (CurrentRState)
1048  {
1049  case rds_Initialise:
1051  break;
1052 
1053  case rds_MOnMature:
1054  switch(MOnMature())
1055  {
1056  case 11:
1058  break;
1059  case 8:
1061  break;
1062  default:
1063  m_OurLandscape ->Warn("Roe_Male::Step():rds_Initialise:No matching case","");
1064  exit( 1 );
1065  break;
1066  }
1067  m_StepDone=true;
1068  break;
1069 
1070  case rds_MDie:
1071  switch (MDie())
1072  {
1073  case 45:
1075  m_StepDone=true;
1076  break;
1077  default:
1078  m_OurLandscape ->Warn("Roe_Male::Step():rds_MDie:No matching case","");
1079  exit( 1 );
1080  break;
1081  }
1082  m_StepDone=true;
1083  break;
1084 
1085  case rds_MOnNewDay:
1086  switch (MOnNewDay())
1087  {
1088  case 5: //rds_MUpdateEnergy
1090  break;
1091  case 40:
1093  break;
1094  case 42: //rds_MDie
1096  break;
1097  default:
1098  m_OurLandscape ->Warn("Roe_Male::Step():rds_MOnNewday:No matching case","");
1099  exit( 1 );
1100  break;
1101  }
1102  break;
1103  case rds_MMate:
1104  switch (MMate())
1105  {
1106  case 36:
1108  break;
1109  default:
1110  m_OurLandscape ->Warn("Roe_Male::Step():rds_MMate:No matching case","");
1111  exit( 1 );
1112  break;
1113  }
1114  m_StepDone=true;
1115  break;
1116  case rds_MEstablishRange:
1117  switch(MEstablishRange())
1118  {
1119  case 36: //rds_MFeed
1121  break;
1122  default:
1123  m_OurLandscape ->Warn("Roe_Male::Step():rds_MEstablishRange:No matching case","");
1124  exit( 1 );
1125  break;
1126  }
1127  m_StepDone=true;
1128  break;
1130  switch(MEstablishTerritory())
1131  {
1132  case 36: //rds_MFeed
1134  break;
1135  default:
1136  m_OurLandscape ->Warn("Roe_Male::Step():rds_MEstablishTerritory:No matching case","");
1137  exit( 1 );
1138  break;
1139  }
1140  m_StepDone=true;
1141  break;
1142  case rds_MDisperse:
1143  switch (MDisperse())
1144  {
1145  case 36: //rds_MFeed
1147  m_StepDone=true;
1148  break;
1149  case 8: //rds_MEstablishRange
1151  m_StepDone=true;
1152  break;
1153  case 11: //rds_MDisperse
1155  m_StepDone=true;
1156  break;
1157  case 42:
1159  break;
1160  default:
1161  m_OurLandscape ->Warn("Roe_Male::Step():rds_MDisperse:No matching case","");
1162  exit( 1 );
1163  break;
1164  }
1165  break;
1166  case rds_MFeed:
1167  switch (MFeed())
1168  {
1169  case 11: //rds_MDisperse
1171  m_StepDone=true;
1172  break;
1173  case 33: //rds_MRuminate
1175  m_StepDone=true;
1176  break;
1177  case 36: //rds_MFeed
1179  m_StepDone=true;
1180  break;
1181  case 42: //rds_MFeed
1183  break;
1184  default:
1185  m_OurLandscape ->Warn("Roe_Male::Step():rds_MFeed:No matching case","");
1186  exit( 1 );
1187  break;
1188  }
1189  break;
1190  case rds_MRecover:
1191  switch(MRecover())
1192  {
1193  case 36: //rds_MFeed:
1195  break;
1196  case 23: //rds_MRecover:
1198  break;
1199  default:
1200  m_OurLandscape ->Warn("Roe_Male::Step():rds_MRecover:No matching case","");
1201  exit( 1 );
1202  break;
1203  }
1204  m_StepDone=true;
1205  break;
1206  case rds_MRun:
1207  switch(MRun())
1208  {
1209  case 23: //rds_MRecover:
1211  break;
1212  case 20: //rds_MRun
1214  break;
1215  default:
1216  m_OurLandscape ->Warn("Roe_Male::Step():rds_MRun:No matching case","");
1217  exit( 1 );
1218  break;
1219  }
1220  m_StepDone=true;
1221  break;
1222  case rds_MEvade:
1223  switch (MEvade())
1224  {
1225  case 11:
1227  break;
1228  case 23:
1230  break;
1231  case 31:
1233  break;
1234  case 33:
1236  break;
1237  case 36:
1239  break;
1240  default:
1241  m_OurLandscape ->Warn("Roe_Male::Step():rds_MEvade:No matching case","");
1242  exit( 1 );
1243  break;
1244  }
1245  m_StepDone=true;
1246  break;
1247  case rds_MIgnore:
1248  switch (MIgnore())
1249  {
1250  case 11:
1252  break;
1253  case 23:
1255  break;
1256  case 31:
1258  break;
1259  case 33:
1261  break;
1262  case 36:
1264  break;
1265  default:
1266  m_OurLandscape ->Warn("Roe_Male::Step():rds_MIgnore:No matching case","");
1267  exit( 1 );
1268  }
1269  m_StepDone=true;
1270  break;
1271  case rds_MRuminate:
1272  switch (MRuminate())
1273  {
1274  case 11:
1276  m_StepDone=true;
1277  break;
1278  case 36: //rds_MFeed:
1280  m_StepDone=true;
1281  break;
1282  case 33: //rds_MRuminate:
1284  m_StepDone=true;
1285  break;
1286  case 42:
1288  break;
1289  default:
1290  m_OurLandscape ->Warn("Roe_Male::Step():rds_MRuminate:No matching case","");
1291  exit( 1 );
1292  break;
1293  }
1294  break;
1295  case rds_MFight:
1296  switch (MFight())
1297  {
1298  case 36: //rds_MFeed:
1300  break;
1301  case 31: //rds_MAttendFemale:
1303  break;
1304  default:
1305  m_OurLandscape ->Warn("Roe_Male::Step():rds_Mfight:No matching case","");
1306  exit( 1 );
1307  break;
1308  }
1309  m_StepDone=true;
1310  break;
1311  case rds_MAttendFemale:
1312  switch (MAttendFemale())
1313  {
1314  case 36: //Feed
1316  m_StepDone=true;
1317  break;
1318  case 31: //rds_MAttendFemale:
1320  break;
1321  default:
1322  m_OurLandscape ->Warn("Roe_Male::Step():rds_MAttendFemale:No matching case","");
1323  exit( 1 );
1324  break;
1325  }
1326  m_StepDone=true;
1327  break;
1328  case rds_MUpdateEnergy:
1329  switch (MUpdateEnergy())
1330  {
1331  case 8: //rds_MEstablishRange
1333  m_StepDone=true;
1334  break;
1335  case 9: //rds_MEstablishTerritory
1337  m_StepDone=true;
1338  break;
1339  case 11: //rds_MDisperse
1341  m_StepDone=true;
1342  break;
1343  case 36: //rds_MFeed
1345  m_StepDone=true;
1346  break;
1347  case 42: //rds_MDie:
1349  break;
1350  case 40: //rds_MMate:
1352  break;
1353  default:
1354  m_OurLandscape ->Warn("Roe_Male::Step():rds_MUpdateEnergy:No matching case","");
1355  exit( 1 );
1356  break;
1357  }
1358  break;
1359  default:
1360  m_OurLandscape ->Warn("Roe_Male::Step():No matching case","");
1361  exit( 1 );
1362  }
1363 }
@ rds_MRecover
Definition: Roe_all.h:69
@ rds_MRuminate
Definition: Roe_all.h:79
@ rds_MFight
Definition: Roe_all.h:76
@ rds_MOnMature
Definition: Roe_all.h:48
@ rds_MEstablishTerritory
Definition: Roe_all.h:55
@ rds_MDie
Definition: Roe_all.h:88
@ rds_Initialise
Definition: Roe_all.h:46
@ rds_MEstablishRange
Definition: Roe_all.h:54
@ rds_MMate
Definition: Roe_all.h:86
@ rds_MUpdateEnergy
Definition: Roe_all.h:51
@ rds_MIgnore
Definition: Roe_all.h:72
int MEstablishTerritory(void)
Definition: Roe_male.cpp:283
int MOnMature(void)
Definition: Roe_male.cpp:32
int MRun()
Definition: Roe_male.cpp:516
int MOnNewDay(void)
Definition: Roe_male.cpp:647
int MIgnore()
Definition: Roe_male.cpp:545
int MEstablishRange(void)
Definition: Roe_male.cpp:73
int MMate(void)
Definition: Roe_male.cpp:828
int MRuminate(void)
Definition: Roe_male.cpp:382
int MAttendFemale(void)
Definition: Roe_male.cpp:606
int MFeed(void)
Definition: Roe_male.cpp:215
int MDisperse(void)
Definition: Roe_male.cpp:136
int MRecover(void)
Definition: Roe_male.cpp:464
int MDie(void)
Definition: Roe_male.cpp:861
int MUpdateEnergy(void)
Definition: Roe_male.cpp:751
int MFight(void)
Definition: Roe_male.cpp:586
int MEvade()
Definition: Roe_male.cpp:564
bool m_StepDone
Indicates whether the iterative step code is done for this timestep.
Definition: PopulationManager.h:118

References Roe_Base::CurrentRState, Roe_Base::IsAlive(), TAnimal::m_OurLandscape, TALMaSSObject::m_StepDone, MAttendFemale(), MDie(), MDisperse(), MEstablishRange(), MEstablishTerritory(), MEvade(), MFeed(), MFight(), MIgnore(), MMate(), MOnMature(), MOnNewDay(), MRecover(), MRuminate(), MRun(), MUpdateEnergy(), rds_Initialise, rds_MAttendFemale, rds_MDeathState, rds_MDie, rds_MDisperse, rds_MEstablishRange, rds_MEstablishTerritory, rds_MEvade, rds_MFeed, rds_MFight, rds_MIgnore, rds_MMate, rds_MOnMature, rds_MOnNewDay, rds_MRecover, rds_MRuminate, rds_MRun, rds_MUpdateEnergy, and Landscape::Warn().

◆ SupplyHaveTerritory()

bool Roe_Male::SupplyHaveTerritory ( )
inline

◆ SupplyHost()

Roe_Male* Roe_Male::SupplyHost ( )
inline
421 {return m_MyTMale;}

Member Data Documentation

◆ m_HaveTerritory

bool Roe_Male::m_HaveTerritory
protected

◆ m_MinInState

◆ m_My_Mate

Roe_Female* Roe_Male::m_My_Mate
protected

◆ m_MyFightlist

int Roe_Male::m_MyFightlist
protected

◆ m_MySatellites

Roe_Male* Roe_Male::m_MySatellites[50]
protected

◆ m_MyTMale

◆ m_NoOfMatings

int Roe_Male::m_NoOfMatings
protected

◆ m_NumberOfFights

int Roe_Male::m_NumberOfFights
protected

The documentation for this class was generated from the following files: